package sum.book.auth.api.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import sum.book.auth.api.fallback.BookOauthServerFallbackFactory;
import sum.book.common.core.model.dto.TokenDTO;

/**
 * @Auther: ZhangGN
 * @Description: client
 * @Date 2022/12/2 12:58
 **/
@FeignClient(value = "book-auth-server")
public interface BookOauthServerClient {
    /**
     * 请求获取Token接口(此处用于密码登录模式)
     *
     * @param basicAuth basicAuth认证信息 必填
     * @param username  用户名 必填
     * @param password  密码 必填
     * @param grantType 认证类型 必填
     * @return
     */
    @RequestMapping(
            method = RequestMethod.POST,
            value = "/uaa/oauth/token",
            consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
            produces = MediaType.APPLICATION_JSON_VALUE)
    ResponseEntity<TokenDTO> token(@RequestHeader("Authorization") String basicAuth,
                                   @RequestParam("username") String username,
                                   @RequestParam("password") String password,
                                   @RequestParam("grant_type") String grantType);
}
